﻿using iBuproModel.Repositories.Classes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using iBuproModel;
using System.Linq;
using System.Collections.Generic;

namespace IBuproModel.Tests
{
    
    
    /// <summary>
    ///This is a test class for SubjectRepositoryTest and is intended
    ///to contain all SubjectRepositoryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SubjectRepositoryTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for SubjectRepository Constructor
        ///</summary>
        [TestMethod()]
        public void SubjectRepositoryConstructorTest()
        {
            SubjectRepository target = new SubjectRepository();
            Assert.IsNotNull(target);
        }


        /// <summary>
        ///A test for GetSubjectsForLector
        ///</summary>
        [TestMethod()]
        public void GetSubjectsForLectorTest()
        {
            try
            {
                InitTest init = new InitTest();
                SubjectRepository target = new SubjectRepository();
                User lector = init.GetUser();

                target.GetSubjectsForLector(lector);
                Assert.Fail();
            }
            catch
            {
               
            }
            
           
        }

        /// <summary>
        ///A test for Hide
        ///</summary>
        [TestMethod()]
        public void HideTest()
        {
            InitTest init = new InitTest();
            SubjectRepository target = new SubjectRepository();
            Subject sub = init.GetSubject();
            int id = sub.Id;
            target.Hide(id);
            target.SaveChanges();
            Assert.IsFalse(sub.Visible);
        }

        /// <summary>
        ///A test for Update
        ///</summary>
        [TestMethod()]
        public void UpdateTest()
        {/*
            InitTest init = new InitTest();
            SubjectRepository target = new SubjectRepository();
            Subject sub = init.GetSubject();
            sub.Visible = false;
            target.Update(sub);
            target.SaveChanges();
            Assert.IsFalse(sub.Visible);
          */
        }

        /// <summary>
        ///A test for UpdateLectorSubjectList
        ///</summary>
        [TestMethod()]
        public void UpdateLectorSubjectListTest()
        {
            InitTest init = new InitTest();
            SubjectRepository target = new SubjectRepository(); 
            User lector = init.GetUser();
            Subject sub = init.GetSubject();
            List<int> ids = new List<int> {sub.Id};

            target.UpdateLectorSubjectList(lector, ids);
            Assert.IsTrue(lector.LectorSubjects.Contains(sub));
        }
    }
}
